package com.cloudOffice.execption;

import com.cloudOffice.enumeration.ResultCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @program: cloud-office
 * @className: SystemException
 * @description: 自定义异常类
 * @data: 2024/2/5 20:22
 * @author: ihu
 * @version: 1.0
 **/

@Data
@ToString
@EqualsAndHashCode(callSuper = true)
public class CustomException extends RuntimeException {
	
	private Integer code;
	
	private String message;
	
	/**
	 * 通过状态码和错误消息创建异常对象
	 */
	public CustomException(Integer code, String message) {
		super(message);
		this.code = code;
		this.message = message;
	}
	
	/**
	 * 接收枚举类型对象
	 */
	public CustomException(ResultCodeEnum resultCodeEnum) {
		super(resultCodeEnum.getMessage());
		this.code = resultCodeEnum.getCode();
		this.message = resultCodeEnum.getMessage();
	}
	
}
